#include <iostream>
#include <cmath>
#include <fstream>

using namespace std;

int main() {
    ifstream in("in.txt", ifstream::in);
    if (!in.is_open()) { cout<<"No input file!\n"; exit(1); }

    int n;

    in>>n;

    double* A = new double[n];
    for (int i = 0; i < n; ++i) { in>>A[i]; }

    int logN = (int)floor(log((double)n) / log(2.0)) + 1;

    int** M = new int*[n];
    for (int i = 0 ; i < n; ++i) { M[i] = new int[logN]; }

    for (int i = 0; i < n; ++i) { M[i][0] = i; }

    for (int i = 1; i < logN; ++i) {
        for (int k = 0; k < n - (1<<i) + 1; ++k) {
            M[k][i] = A[ M[k][i - 1] ] < A[ M[k + (1<<(i-1))][i-1] ] ? M[k][i - 1] : M[k + (1<<(i-1))][i-1];
        }
    }

    int requestCount;
    in>>requestCount; // для работы под acm.mipt

    while (in.good()) {
        int a, b;
        in>>a>>b;
        b--; // для работы под acm.mipt

        int k = (int)floor(log((double)b - a + 1) / log(2.0));
        cout<<min(A[M[a][k]], A[M[b - (1<<k) + 1][k]])<<endl;
    }

    system("pause");
    return 0;
}
